package chapter14;

import java.util.Objects;

/**
 * Created by Caesar on 2016/2/26.
 */

class test1{
    test1(){}
}
class test2 extends test1{
    test2(){}
}
class test3 extends test2{
    test3(){}
}
public class Test8 {
    public void extend(Class obj){
        Class up =obj.getSuperclass();
        Object ob1 = null;
        if(up != null) {
            extend(up);
        }else return;
        try {
            System.out.println(obj.newInstance().getClass());
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        Test8 t2 = new Test8();
        try {
            t2.extend(Class.forName("chapter14.test3"));
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

}
